/*
 * @Description: 
 * @Date: 2024-05-23 10:15:54
 * @LastEditTime: 2024-09-10 14:46:58
 */
import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
import { dateFormatter } from '@/utils/formatTime'

// 表单校验
export const rules = reactive({
  content: [required],
  title: [required],
  pushTime: [required],
})

// CrudSchema https://doc.iocoder.cn/vue3/crud-schema/
const crudSchemas = reactive<CrudSchema[]>([
  {
    label: '编号',
    field: 'id',
    isForm: false,
  },
  {
    label: '内容',
    field: 'content',
    isSearch: true,
    form: {
      component: 'Editor',
      componentProps: {
        valueHtml: '',
        height: 200
      }
    },
    table:{
      show:false
    }
  },
  {
    label: '作者',
    field: 'author',
    isSearch: true,
  },
  {
    label: '来源',
    field: 'source',
    isSearch: true,
  },
  {
    label: '标题',
    field: 'title',
    isSearch: true,
  },
  {
     label:"图片",
     field:"imageUrl",
     isSearch:false,
     form:{
      component:"UploadImg"
     }
  },
  {
    label: '发布时间',
    field: 'pushTime',
    formatter: dateFormatter,
    isSearch: true,
    search: {
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        type: 'daterange',
        defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
      }
    },
    form: {
      component: 'DatePicker',
      componentProps: {
        type: 'datetime',
        valueFormat: 'x'
      }
    },
  },
  {
    label: '创建时间',
    field: 'createTime',
    formatter: dateFormatter,
    isSearch: true,
    search: {
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
        type: 'daterange',
        defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
      }
    },
    isForm: false,
  },
  {
    label: '操作',
    field: 'action',
    isForm: false
  }
])
export const { allSchemas } = useCrudSchemas(crudSchemas)
